package com.easypan.utils.minio.config;

import io.minio.MinioClient;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Data
@Configuration
@ConfigurationProperties(prefix = "minio")
public class MinioConfig {
    @Value("${minio.endpoint}")
    private String endpoint;
    @Value("${minio.access-key}")
    private String accessKey;
    @Value("${minio.secret-key}")
    private String secretKey;
    @Value("${minio.bucket-name}")
    private String bucketName;
    @Value("${minio.expires}")
    private Integer expires;
    @Value("${minio.respone-prefix-url}")
    private String responePrefixUrl;

    @Value("${spring.servlet.multipart.max-file-size}")
    private String  maxFileSize;

    @Bean
    public MinioClient miniosClient(){
        return MinioClient.builder().endpoint(endpoint).credentials(accessKey,secretKey).build();
    }

    public String getPath(){
        return responePrefixUrl+"/"+bucketName+"/";
    }
}
